Skip to content

Fix possible integer overflow in the standard worker loop in the docs - #2599

Closed
gggeek wants to merge 1 commit into
php:mainfrom
gggeek:gg/improve_default_worker_look_example
Closed

Fix possible integer overflow in the standard worker loop in the docs#2599
gggeek wants to merge 1 commit into
php:mainfrom
gggeek:gg/improve_default_worker_look_example

Conversation

@gggeek

@gggeek gggeek commented Aug 11, 2026

Copy link
Copy Markdown

If $_SERVER['MAX_REQUESTS'] is unset or 0, the for loop as originally shown would overflow the $nbRequests variable in the end.

Not that I did experience that, but I think that it would have resulted in an error page at some point (for a very, very busy server).

The code changes this to exit the worker cleanly instead.

I think this is better, even though it is just slightly less readable.

@henderkes

Copy link
Copy Markdown
Contributor

Not that I did experience that, but I think that it would have resulted in an error page at some point (for a very, very busy server).

In PHP integers don't underflow but instead get promoted to floats. At some point the next available double is going to be further than 1 step away and $var++ does nothing.

@henderkes henderkes closed this Aug 11, 2026
@gggeek

gggeek commented Aug 11, 2026

Copy link
Copy Markdown
Author

In PHP integers don't underflow but instead get promoted to floats

One never stops learning 馃槉
Sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants